package net.mihome.app.ui;

import net.mihome.app.R;
import net.mihome.app.bean.NewsType;
import net.mihome.app.bean.Shop;
import net.mihome.app.ui.view.MihomeShopMenuView;
import net.mihome.app.ui.view.MihomeZixunView;
import net.mihome.app.ui.view.MyViewLinster;
import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.View;
import android.widget.ProgressBar;
import android.widget.TextView;

public class MihomeShopMenusActivity extends BaseActivity {
	MihomeShopMenuView mihomeZixunView;
	ProgressBar progressBar;
	Handler handler;
	public static final int STOP_PROGRESS=1;
	public static final int START_PROGRESS=2;
	TextView titleTextView;
	Shop shop;
	int shop_id=0;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.mihome_shop_menus_main);
		shop=(Shop) getIntent().getSerializableExtra("shop");
		titleTextView=(TextView) findViewById(R.id.mihome_list_head_title_id);
		titleTextView.setText(shop.getName());
		shop_id=shop.getId();
		handler=new Handler(new Handler.Callback() {
			@Override
			public boolean handleMessage(Message arg0) {
				switch (arg0.what) {
				case STOP_PROGRESS:
					progressBar.setVisibility(View.GONE);
					break;
				case START_PROGRESS:
					progressBar.setVisibility(View.VISIBLE);
					break;
				default:
					break;
				}
				return false;
			}
		});
		progressBar=(ProgressBar) findViewById(R.id.news_list_head_progress);
		mihomeZixunView=(MihomeShopMenuView) findViewById(R.id.mihome_shop_menu_listview);
		mihomeZixunView.setMyViewLinster(new MyViewLinster() {
			@Override
			public void onLoadComplete() {
				// TODO Auto-generated method stub
				handler.sendEmptyMessage(STOP_PROGRESS);
			}
			@Override
			public void onBeforeLoad() {
				// TODO Auto-generated method stub
				handler.sendEmptyMessage(START_PROGRESS);
				
			}
		});
		mihomeZixunView.initData(shop.getId());
	}
}
